package controller

import (
	"lnzw/engine/http"
	"lnzw/server/urlsvr/define"
	"lnzw/server/urlsvr/selector"

	"github.com/gin-gonic/gin"
)

func Gate(ctx *gin.Context) {

	gate, err := selector.DEFAULT.Select()
	if err == selector.ERR_NONE_SERVERS {
		ctx.JSON(200, http.JsonFail("have none gate server", define.RESULT_CODE_NOT_HAVE_SERVERS))
		return
	}
	if err != nil {
		ctx.JSON(200, http.JsonFail("select gate server error", http.RESULT_CODE_UNKNOW_FAIL))
		return
	}
	ctx.JSON(200, http.JsonSuccess(gate))
}
